
var class_name_slide_nav="fold_slide_nav";
var class_name_slide="fold_slide";
var class_name_slide_fixed="fold_slide_fixed";
var class_name_header_logo="fold_header_logo";
export function toggle_unfold(app_slide_fixed:Element,app_body_slide:Element,app_body_slide_nav:Element,app_slide_toggle:Element,app_header_logo:Element) {
    app_slide_fixed.classList.remove(class_name_slide_fixed)
    app_body_slide.classList.remove(class_name_slide);
    app_body_slide_nav.classList.remove(class_name_slide_nav);
    app_header_logo.classList.remove(class_name_header_logo);
    app_slide_toggle.classList.remove("bi-text-indent-left");
    app_slide_toggle.classList.add("bi-text-indent-right");
    let el = document.querySelector("#app_body_slide_logo li:first-of-type") as HTMLElement;
    el.style.borderTopRightRadius="var(--bs-border-radius)";
}
export function toggle_fold(app_slide_fixed:Element,app_body_slide:Element,app_body_slide_nav:Element,app_slide_toggle:Element,app_header_logo:Element) {
    app_slide_fixed.classList.add(class_name_slide_fixed)
    app_body_slide.classList.add(class_name_slide);
    app_body_slide_nav.classList.add(class_name_slide_nav);
    app_header_logo.classList.add(class_name_header_logo);
    app_slide_toggle.classList.remove("bi-text-indent-right");
    app_slide_toggle.classList.add("bi-text-indent-left");
    let el = document.querySelector("#app_body_slide_logo li:first-of-type") as HTMLElement;
    el.style.borderTopRightRadius="0px";
    // el.style.color="red";
    
}
export function toggle(force_unfold=false) {
    
    let app_slide_fixed=document.querySelector("#app_body_slide__fixed");
    let app_slide_toggle=document.querySelector("#app_slide_toggle i");
    let app_header_logo=document.querySelector("#app_header_logo");
    let app_body_slide=document.querySelector("#app_body_slide");
    let app_body_slide_nav=document.querySelector("#app_body_slide_nav");
    
    if(!app_slide_fixed||!app_slide_toggle||!app_header_logo||!app_body_slide||!app_body_slide_nav){
        return;
    }
    if(force_unfold){
        toggle_unfold(app_slide_fixed, app_body_slide, app_body_slide_nav,app_slide_toggle,app_header_logo);
        return;
    }
    if(app_body_slide.classList.contains("fold_slide")){
        toggle_unfold(app_slide_fixed,app_body_slide,app_body_slide_nav,app_slide_toggle,app_header_logo);
    }else{
        toggle_fold(app_slide_fixed,app_body_slide,app_body_slide_nav,app_slide_toggle,app_header_logo);
    }
    
}
export default function bind_toggle(id:string) {
   let btn = document.querySelector(id);
   if(!btn){
    return;
   }
   btn.addEventListener("click",function name(params:Event) {
        console.log("click!");
        toggle();
        
   })
}